execute store result score @s advm_chargeable run data get entity @s Item.tag.chargeable
execute store result score @s advm_power run data get entity @s Item.tag.power
execute store result score @s advm_power_max run data get entity @s Item.tag.max
execute at @s if score @s advm_chargeable matches 1 if score @s advm_power < @s advm_power_max run tag @e[distance=..1.5,type=item_frame,nbt={Tags:["wire"]},tag=hasPower,limit=1,sort=random] remove hasPower
execute at @s if score @s advm_chargeable matches 1 if score @s advm_power < @s advm_power_max run scoreboard players add @s advm_power 1
execute at @s if score @s advm_chargeable matches 1 if score @s advm_power <= @s advm_power_max store result entity @s Item.tag.power int 1 run scoreboard players get @s advm_power

title @a[distance=..2] actionbar [{"score":{"name": "@s","objective": "advm_power"}},{"text":"/","italic": false},{"score":{"name": "@s","objective": "advm_power_max"}},{"text":" ⚡","italic": false}]

execute at @s if score @s advm_power >= @s advm_power_max run setblock ~ ~-1 ~ green_glazed_terracotta replace
execute at @s if score @s advm_chargeable matches 1 if score @s advm_power < @s advm_power_max run setblock ~ ~-1 ~ red_glazed_terracotta replace